{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--BOOK_INFORMATION-->\n",
    "<a href=\"https://www.packtpub.com/big-data-and-business-intelligence/machine-learning-opencv\" target=\"_blank\"><img align=\"left\" src=\"data/cover.jpg\" style=\"width: 76px; height: 100px; background: white; padding: 1px; border: 1px solid black; margin-right:10px;\"></a>\n",
    "*This notebook contains an excerpt from the book [Machine Learning for OpenCV](https://www.packtpub.com/big-data-and-business-intelligence/machine-learning-opencv) by Michael Beyeler.\n",
    "The code is released under the [MIT license](https://opensource.org/licenses/MIT),\n",
    "and is available on [GitHub](https://github.com/mbeyeler/opencv-machine-learning).*\n",
    "\n",
    "*Note that this excerpt contains only the raw code - the book is rich with additional explanations and illustrations.\n",
    "If you find this content useful, please consider supporting the work by\n",
    "[buying the book](https://www.packtpub.com/big-data-and-business-intelligence/machine-learning-opencv)!*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--NAVIGATION-->\n",
    "< [Detecting Pedestrians with Support Vector Machines](06.03-Additional-SVM-Exercises.ipynb) | [Contents](../README.md) | [Implementing Our First Bayesian Classifier](07.01-Implementing-Our-First-Bayesian-Classifier.ipynb) >"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Implementing a Spam Filter with Bayesian Learning\n",
    "\n",
    "Before we get to grips with advanced topics, such as cluster analysis, deep learning, and\n",
    "ensemble models, let's turn our attention to a much simpler model that we have overlooked\n",
    "so far: the **naive Bayes classifier**.\n",
    "\n",
    "Naive Bayes classifiers have their roots in **Bayesian inference**, named after famed\n",
    "statistician and philosopher Thomas Bayes (1701-1761). **Bayes' theorem** famously describes\n",
    "the **probability** of an event based on **prior knowledge** of conditions that might lead to the\n",
    "event. We can use Bayes' theorem to build a statistical model that can not only classify data\n",
    "but also provide us with an estimate of how likely it is that our classification is correct. In\n",
    "our case, we can use Bayesian inference to dismiss an email as spam with high confidence,\n",
    "and to determine the probability of a woman having breast cancer, given a positive\n",
    "screening test.\n",
    "\n",
    "We have now gained enough experience with the mechanics of implementing machine\n",
    "learning methods, and so we should no longer be afraid to try and understand the theory\n",
    "behind them. Don't worry, we won't write a book on it (ahem), but we need some\n",
    "understanding of the theory to appreciate a model's inner workings. After that, I am sure\n",
    "you will find that Bayesian classifiers are easy to implement, computationally efficient, and\n",
    "tend to perform quite well on relatively small datasets.\n",
    "\n",
    "Along the way, we also want to address the following questions:\n",
    "- What makes a naive Bayes classifier so darn naive in the first place?\n",
    "- What is the difference between discriminative and generative models?\n",
    "- How do I implement Bayesian classifiers in OpenCV and how do I use them to detect fraudulent email messages?\n",
    "\n",
    "## Outline\n",
    "- [Implementing Our First Bayesian Classifier](07.01-Implementing-Our-First-Bayesian-Classifier.ipynb)\n",
    "- [Classifying E-Mails Using Naive Bayes](07.02-Classifying-Emails-Using-Naive-Bayes.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--NAVIGATION-->\n",
    "< [Detecting Pedestrians with Support Vector Machines](06.03-Additional-SVM-Exercises.ipynb) | [Contents](../README.md) | [Implementing Our First Bayesian Classifier](07.01-Implementing-Our-First-Bayesian-Classifier.ipynb) >"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
